{template 'header', $module}
<div class="main-block bd-gray">
	<div class="hd fn-clear">
		<h2 class="fn-left">在线店</h2>
	</div>
	<form method="post" class="form" action="{url('member/store')}" id="pub-form">
	<div id="tab_store" class='root'>
		<span class="licence_status_0 licence_staus" {if !$status}style="display:block"{else}style="display:none;"{/if}>
		当前没有提交在线店信息, 请填写信息后点击保存.
		</span>
		<span class="licence_status_1 licence_staus" {if $status == 1}style="display:block"{else}style="display:none;"{/if}>
		在线店信息审核失败！ 请修改后重新上传！
		</span>
		<span class="licence_status_2 licence_staus" {if $status == 2}style="display:block"{else}style="display:none;"{/if}>
		在线店信息提交成功,请等待审核
		</span>
		<span class="licence_status_3 licence_staus" {if $status == 3}style="display:block"{else}style="display:none;"{/if}>
		在线店信息审核成功
		</span>
		<table class="data-form c666 mt10">
			<tr>
				<th width="90">企业名称：</th>
				<td class="tr f_b"><input type="text" name="post[company]" size='45' class="graybd-ipt easyui-validatebox" data-options="required:true,validType:'length[2,50]',invalidMessage:'长度在2-50内',missingMessage:'请填写企业名称'" value="{$company}"></td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span>形象图片：</th>
				<td>{Post::picture($moduleid, 'thumb', 'post[thumb]', $item['thumb'] ,310, 206)}</td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span>在线店类型：</th>
				<td>
					<input id="chooseCat" type="button" value="选择/修改"/>请选择主营行业。
				</td>
			</tr>
			<tr>
				<th width="90">已选类型：</th>
				<td>
					<ul id="selectedCats" class="fn-clear" name="select">
						{loop $cates $t}
						{if $t}
						<li id="{$t}" class="fn-left fn-clear mr5">
							<span class="fn-left">{get_cache_category_name(40,$t)}</span>
							<a href="javascript:void(0);" title="删除此项" class="del fn-left"></a>
						</li>
						{/if}
						{/loop}
					</ul>
					<select name="post[catid][]" multiple="multiple" id="cates" size="2" style="display: none;">
						{loop $cates $t}
						<option id="{$t}" value="{$t}" selected="selected">{get_cache_category_name(4,$t)}</option>
						{/loop}
					</select>
				</td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span>主营范围：</th>
				<td class="tr">
					<textarea name="post[business]" id="business" cols="80" rows="3">{$business}</textarea>
				</td>
			</tr>
            <tr>
                <th>汽车品牌：</th>
                <td>
                    <div id="J_FilterInitials" class="filter-initial fn-clear">
                        <ul>
	                        {php $keys = array_keys($LBRANDS)}
	                        {php $az = range('A', 'Z')}
	                        {loop $az $lt}
                            <li {if !in_array($lt, $keys)}class="unselect"{/if}>{$lt}</li>
	                        {/loop}
                        </ul>
                    </div>
                    <div id="J_AutoBrands" class="brands-list">
	                    {loop $LBRANDS $letter $brands}
                        <div id="letter{$letter}" class="brands fn-clear">
                            <h4>{$letter}</h4>
                            <ul>
	                            {if $brands}
	                            {loop $brands $brand}
                                <li><label><input name="post[brandId][]" type="checkbox" {if in_array($brand['brandId'], $arbids)}checked="checked"{/if} value="{$brand['brandId']}"><span>{$brand['brandShortName']}</span></label></li>
                                {/loop}
	                            {/if}
                            </ul>
                        </div>
	                    {/loop}
                    </div>
                    <ul id="J_BSelected" class="brands-sel mt10 fn-clear">
	                    {if $selectedBrands}
	                    {loop $selectedBrands $brand}
                        <li id="{$brand['arid']}" class="fn-left fn-clear mr10">
                            <span class="fn-left">{$brand['name']}</span>
                            <a href="javascript:void(0);" title="删除此品牌" class="del fn-left"></a>
                        </li>
	                    {/loop}
	                    {/if}
                    </ul>
                </td>
            </tr>
			<tr>
				<th width="90"><span class="cred">*</span>所在地区：</th>
				<td class="tr">{Post::areaCombo('post[areaid]', $areaid)}</td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span>企业地址：</th>
				<td class="tr"><input type="text" size="60" name="post[address]" class="graybd-ipt easyui-validatebox" data-options="required:true,validType:'length[2,50]',invalidMessage:'长度在2-50内',missingMessage:'请填写企业地址'" value="{$address}" maxlength="200"/>&nbsp;<span id="ddaddress" class="cred"></span></td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span>联系电话：</th>
				<td class="tr"><input type="text" size="20" name="post[telephone]" class="graybd-ipt easyui-validatebox" data-options="required:true,missingMessage:'请填写企业电话'"  value="{$telephone}"/>&nbsp;<span id="dtelephone" class="cred"></span></td>
			</tr>
			<tr>
				<th width="90"><span class="cred">*</span> 在线店介绍</th>
				<td width="680">
					{Post::kindEditor('post[content]', $moduleid, $item['content'],'','675px','280px')}
					<span>提示：请点击<img src="{IMG_URL}Common/store_tip.jpg" style="vertical-align: middle">上传您企业宣传图片资料，您上传的图片资料将被用于在线店展示</span>
				</td>
			</tr>
			<tr>
				<th width="50">我的位置</th>
				<td class="tr">
                    <input type="text" id="location"  readonly="readonly" {if $langitude && $latitude}value="{$langitude},{$latitude}"{/if} size='40' class=" graybd-ipt fn-left mr10"/>
                    <input type="hidden" readonly="readonly" id="point" name="post[position]"  size="40" class=" graybd-ipt fn-left mr10" value="{if $langitude && $latitude }{$langitude},{$latitude}{/if}"/>
					<button id="markLoc" class="btn fn-left" type="button">标注位置</button>
				</td>
			</tr>
		</table>
		<!--主营行业 对话框 start-->
		<div style="display: none">
			<div id="companyCat" title="选择分类" class="easyui-dialog"  style="padding:10px;" data-options="closed:'true'">
				<div class="company-cat">
					{Ext::categoryHtml($cartree)}
				</div>
			</div>
		</div>
		<!--主营行业 对话框 end-->
		<script>
            seajs.use(['$','lm-util','mod-catSelection'],function($,util,CatSel){
                //主营行业选择
                var catSel = new CatSel('chooseCat','companyCat','selectedCats','cates',false);
                catSel.run();

                //品牌选择
                $("#J_FilterInitials>ul>li:not(.unselect)").click(function(){
                    var isSelected = $(this).hasClass("selected"),
                            letter = $.trim($(this).text());
                    if(isSelected){
                        $(this).removeClass("selected");
                        $("#J_AutoBrands>.brands").show();
                    }else{
                        $(this).addClass("selected").siblings("li").removeClass("selected");
                        $("#J_AutoBrands>.brands").hide();
                        $("#letter"+letter).show();
                    }
                });
                $("#J_AutoBrands input").click(function(){
                    var isSelected = $(this).prop("checked"),
                            selId = $(this).val(),
                            selName = $.trim($(this).siblings('span').text()),
                            selNum = $("#J_AutoBrands input:checked").length;
                    if( selNum > 20 ){
                        $(this).prop("checked",false);
                        util.showTip({type:"error",message:"品牌最多只能选择20个",top:'0'});
                        return;
                    }
                    if( !isSelected ){
                        $("#J_BSelected>#"+selId).remove();
                    }else{
                        var html = '<li id="'+selId+'" class="fn-left fn-clear mr10">'+
                                '<span class="fn-left">'+selName+'</span>'+
                                '<a href="javascript:void(0);" title="删除此品牌" class="del fn-left"></a>'+
                                '</li>';
                        $("#J_BSelected").append(html);
                    }
                });
                //删除品牌
                $("#J_BSelected").on("click","a.del",function(){
                    var brandId = $(this).parent('li').attr("id");
                    $(this).parent('li').remove();
                    $("#J_AutoBrands input[value="+brandId+"]").prop("checked",false);
                });

	            $('#pub-form').form({
		            success: function(data){
			            var data = eval('(' + data + ')');
			            if (!data.success){
				            alert(data.message);
				            return false;
			            }else{
				            alert(data.message);
				            window.location.reload()
			            }
		            }
	            });
            });
		</script>
	</div>
	<div class="con pl105 fn-clear">
		<button type="submit" class="fn-left mr20 btn">保 存</button>
		<button type="button" class="btn" onclick="history.back(-1);">返回</button>
	</div>
	</form>
</div>
<!--map start-->
<div id="mapDlgWrap" style="display:none;">
	<div id="mapDlg" class="easyui-dialog" title="标注位置" style="padding:10px;text-align: center" data-options="closed:'true'">
		<p style="text-align:left;color:red;">温馨提示：您可以在地图中点击右键添加标注。</p>
		{php $currentAreaid = Area::area2id(Area::ip2area($DT_IP))}
		<iframe width="500" height="350" border='0' src="{SITE_URL}api.php?aM=map&aA=member&city={if $langitude && $latitude}{$langitude},{$latitude}{elseif $areaid}{Area::pos($areaid,'')}{$address}{else}{urlencode('中国')}{/if}" frameborder='0' scrolling="no"></iframe>
	</div>
</div>
<!--map end-->
{template 'footer', $module}